home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / Dialogs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  15.0 KB  |  409 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Dialogs.h
  3.  
  4.      Contains:    Dialog Manager interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1.3
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __DIALOGS__
  21. #define __DIALOGS__
  22.  
  23.  
  24. #ifndef __ERRORS__
  25. #include <Errors.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __MEMORY__
  30. #include <Memory.h>
  31. #endif
  32. /*    #include <Types.h>                                            */
  33. /*    #include <MixedMode.h>                                        */
  34.  
  35. #ifndef __MENUS__
  36. #include <Menus.h>
  37. #endif
  38. /*    #include <Quickdraw.h>                                        */
  39. /*        #include <QuickdrawText.h>                                */
  40.  
  41. #ifndef __CONTROLS__
  42. #include <Controls.h>
  43. #endif
  44.  
  45. #ifndef __WINDOWS__
  46. #include <Windows.h>
  47. #endif
  48. /*    #include <Events.h>                                            */
  49. /*        #include <OSUtils.h>                                    */
  50.  
  51. #ifndef __TEXTEDIT__
  52. #include <TextEdit.h>
  53. #endif
  54.  
  55. #ifndef __EVENTS__
  56. #include <Events.h>
  57. #endif
  58.  
  59. #ifdef __cplusplus
  60. extern "C" {
  61. #endif
  62.  
  63. #if PRAGMA_ALIGN_SUPPORTED
  64. #pragma options align=mac68k
  65. #endif
  66.  
  67. #if PRAGMA_IMPORT_SUPPORTED
  68. #pragma import on
  69. #endif
  70.  
  71.  
  72. enum {
  73.     ctrlItem                    = 4,
  74.     btnCtrl                        = 0,
  75.     chkCtrl                        = 1,
  76.     radCtrl                        = 2,
  77.     resCtrl                        = 3,
  78.     statText                    = 8,
  79.     editText                    = 16,
  80.     iconItem                    = 32,
  81.     picItem                        = 64,
  82.     userItem                    = 0,
  83.     itemDisable                    = 128,
  84.     ok                            = 1,
  85.     cancel                        = 2,
  86.     stopIcon                    = 0,
  87.     noteIcon                    = 1,
  88.     cautionIcon                    = 2
  89. };
  90.  
  91. /* new, more standard names for dialog item constants */
  92. enum {
  93.     kControlDialogItem            = ctrlItem,
  94.     kButtonDialogItem            = ctrlItem + btnCtrl,
  95.     kCheckBoxDialogItem            = ctrlItem + chkCtrl,
  96.     kRadioButtonDialogItem        = ctrlItem + radCtrl,
  97.     kResourceControlDialogItem    = ctrlItem + resCtrl,
  98.     kStaticTextDialogItem        = statText,
  99.     kEditTextDialogItem            = editText,
  100.     kIconDialogItem                = iconItem,
  101.     kPictureDialogItem            = picItem,
  102.     kUserDialogItem                = userItem,
  103.     kItemDisableBit                = itemDisable,
  104.     kStdOkItemIndex                = ok,
  105.     kStdCancelItemIndex            = cancel,
  106.     kStopIcon                    = stopIcon,
  107.     kNoteIcon                    = noteIcon,
  108.     kCautionIcon                = cautionIcon
  109. };
  110.  
  111. #if OLDROUTINENAMES
  112. enum {
  113.     kOkItemIndex                = kStdOkItemIndex,
  114.     kCancelItemIndex            = kStdCancelItemIndex
  115. };
  116.  
  117. #endif
  118. typedef SInt16 DITLMethod;
  119.  
  120.  
  121. enum {
  122.     overlayDITL                    = 0,
  123.     appendDITLRight                = 1,
  124.     appendDITLBottom            = 2
  125. };
  126.  
  127. typedef short StageList;
  128.  
  129. typedef OSType DialogPropertyTag;
  130.  
  131. typedef WindowPtr DialogPtr;
  132.  
  133. typedef DialogPtr DialogRef;
  134.  
  135.  
  136. typedef pascal void (*SoundProcPtr)(short soundNumber);
  137. typedef pascal Boolean (*ModalFilterProcPtr)(DialogPtr theDialog, EventRecord *theEvent, short *itemHit);
  138. typedef pascal void (*UserItemProcPtr)(WindowPtr theWindow, short itemNo);
  139.  
  140. #if GENERATINGCFM
  141. typedef UniversalProcPtr SoundUPP;
  142. typedef UniversalProcPtr ModalFilterUPP;
  143. typedef UniversalProcPtr UserItemUPP;
  144. #else
  145. typedef SoundProcPtr SoundUPP;
  146. typedef ModalFilterProcPtr ModalFilterUPP;
  147. typedef UserItemProcPtr UserItemUPP;
  148. #endif
  149.  
  150. enum {
  151.     uppSoundProcInfo = kPascalStackBased
  152.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short))),
  153.     uppModalFilterProcInfo = kPascalStackBased
  154.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  155.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DialogPtr)))
  156.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(EventRecord*)))
  157.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short*))),
  158.     uppUserItemProcInfo = kPascalStackBased
  159.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr)))
  160.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  161. };
  162.  
  163. #if GENERATINGCFM
  164. #define NewSoundProc(userRoutine)        \
  165.         (SoundUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSoundProcInfo, GetCurrentArchitecture())
  166. #define NewModalFilterProc(userRoutine)        \
  167.         (ModalFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppModalFilterProcInfo, GetCurrentArchitecture())
  168. #define NewUserItemProc(userRoutine)        \
  169.         (UserItemUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppUserItemProcInfo, GetCurrentArchitecture())
  170. #else
  171. #define NewSoundProc(userRoutine)        \
  172.         ((SoundUPP) (userRoutine))
  173. #define NewModalFilterProc(userRoutine)        \
  174.         ((ModalFilterUPP) (userRoutine))
  175. #define NewUserItemProc(userRoutine)        \
  176.         ((UserItemUPP) (userRoutine))
  177. #endif
  178.  
  179. #if GENERATINGCFM
  180. #define CallSoundProc(userRoutine, soundNumber)        \
  181.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSoundProcInfo, (soundNumber))
  182. #define CallModalFilterProc(userRoutine, theDialog, theEvent, itemHit)        \
  183.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppModalFilterProcInfo, (theDialog), (theEvent), (itemHit))
  184. #define CallUserItemProc(userRoutine, theWindow, itemNo)        \
  185.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppUserItemProcInfo, (theWindow), (itemNo))
  186. #else
  187. #define CallSoundProc(userRoutine, soundNumber)        \
  188.         (*(userRoutine))((soundNumber))
  189. #define CallModalFilterProc(userRoutine, theDialog, theEvent, itemHit)        \
  190.         (*(userRoutine))((theDialog), (theEvent), (itemHit))
  191. #define CallUserItemProc(userRoutine, theWindow, itemNo)        \
  192.         (*(userRoutine))((theWindow), (itemNo))
  193. #endif
  194.  
  195. struct DialogRecord {
  196.     WindowRecord                    window;
  197.     Handle                            items;
  198.     TEHandle                        textH;
  199.     short                            editField;
  200.     short                            editOpen;
  201.     short                            aDefItem;
  202. };
  203. typedef struct DialogRecord DialogRecord;
  204.  
  205. typedef DialogRecord *DialogPeek;
  206.  
  207. struct DialogTemplate {
  208.     Rect                            boundsRect;
  209.     short                            procID;
  210.     Boolean                            visible;
  211.     Boolean                            filler1;
  212.     Boolean                            goAwayFlag;
  213.     Boolean                            filler2;
  214.     long                            refCon;
  215.     short                            itemsID;
  216.     Str255                            title;
  217. };
  218. typedef struct DialogTemplate DialogTemplate;
  219.  
  220. typedef DialogTemplate *DialogTPtr, **DialogTHndl;
  221.  
  222. struct AlertTemplate {
  223.     Rect                            boundsRect;
  224.     short                            itemsID;
  225.     StageList                        stages;
  226. };
  227. typedef struct AlertTemplate AlertTemplate;
  228.  
  229. typedef AlertTemplate *AlertTPtr, **AlertTHndl;
  230.  
  231. extern pascal void InitDialogs(void *ignored)
  232.  ONEWORDINLINE(0xA97B);
  233. extern pascal void ErrorSound(SoundUPP soundProc)
  234.  ONEWORDINLINE(0xA98C);
  235. extern pascal DialogRef NewDialog(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle itmLstHndl)
  236.  ONEWORDINLINE(0xA97D);
  237. extern pascal DialogRef GetNewDialog(short dialogID, void *dStorage, WindowRef behind)
  238.  ONEWORDINLINE(0xA97C);
  239. extern pascal void CloseDialog(DialogRef theDialog)
  240.  ONEWORDINLINE(0xA982);
  241. extern pascal void DisposeDialog(DialogRef theDialog)
  242.  ONEWORDINLINE(0xA983);
  243. extern pascal void ParamText(ConstStr255Param param0, ConstStr255Param param1, ConstStr255Param param2, ConstStr255Param param3)
  244.  ONEWORDINLINE(0xA98B);
  245. extern pascal void ModalDialog(ModalFilterUPP modalFilter, short *itemHit)
  246.  ONEWORDINLINE(0xA991);
  247. extern pascal Boolean IsDialogEvent(const EventRecord *theEvent)
  248.  ONEWORDINLINE(0xA97F);
  249. extern pascal Boolean DialogSelect(const EventRecord *theEvent, DialogRef *theDialog, short *itemHit)
  250.  ONEWORDINLINE(0xA980);
  251. extern pascal void DrawDialog(DialogRef theDialog)
  252.  ONEWORDINLINE(0xA981);
  253. extern pascal void UpdateDialog(DialogRef theDialog, RgnHandle updateRgn)
  254.  ONEWORDINLINE(0xA978);
  255. extern pascal short Alert(short alertID, ModalFilterUPP modalFilter)
  256.  ONEWORDINLINE(0xA985);
  257. extern pascal short StopAlert(short alertID, ModalFilterUPP modalFilter)
  258.  ONEWORDINLINE(0xA986);
  259. extern pascal short NoteAlert(short alertID, ModalFilterUPP modalFilter)
  260.  ONEWORDINLINE(0xA987);
  261. extern pascal short CautionAlert(short alertID, ModalFilterUPP modalFilter)
  262.  ONEWORDINLINE(0xA988);
  263. extern pascal void GetDialogItem(DialogRef theDialog, short itemNo, short *itemType, Handle *item, Rect *box)
  264.  ONEWORDINLINE(0xA98D);
  265. extern pascal void SetDialogItem(DialogRef theDialog, short itemNo, short itemType, Handle item, const Rect *box)
  266.  ONEWORDINLINE(0xA98E);
  267. extern pascal void HideDialogItem(DialogRef theDialog, short itemNo)
  268.  ONEWORDINLINE(0xA827);
  269. extern pascal void ShowDialogItem(DialogRef theDialog, short itemNo)
  270.  ONEWORDINLINE(0xA828);
  271. extern pascal void SelectDialogItemText(DialogRef theDialog, short itemNo, short strtSel, short endSel)
  272.  ONEWORDINLINE(0xA97E);
  273. extern pascal void GetDialogItemText(Handle item, Str255 text)
  274.  ONEWORDINLINE(0xA990);
  275. extern pascal void SetDialogItemText(Handle item, ConstStr255Param text)
  276.  ONEWORDINLINE(0xA98F);
  277. extern pascal short FindDialogItem(DialogRef theDialog, Point thePt)
  278.  ONEWORDINLINE(0xA984);
  279. extern pascal DialogRef NewColorDialog(void *dStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle items)
  280.  ONEWORDINLINE(0xAA4B);
  281. extern pascal short GetAlertStage( void )
  282.     TWOWORDINLINE( 0x3EB8, 0x0A9A ); /* MOVE.w $0A9A,(SP) */
  283. extern DialogRef newdialog(void *wStorage, const Rect *boundsRect, const char *title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle itmLstHndl);
  284. extern DialogRef newcolordialog(void *dStorage, const Rect *boundsRect, const char *title, Boolean visible, short procID, WindowRef behind, Boolean goAwayFlag, long refCon, Handle items);
  285. extern pascal void ResetAlertStage(void)
  286.  TWOWORDINLINE(0x4278, 0x0A9A);
  287. extern pascal void DialogCut(DialogRef theDialog);
  288. extern pascal void DialogPaste(DialogRef theDialog);
  289. extern pascal void DialogCopy(DialogRef theDialog);
  290. extern pascal void DialogDelete(DialogRef theDialog);
  291. extern pascal void SetDialogFont( short value )
  292.     TWOWORDINLINE( 0x31DF, 0x0AFA ); /* MOVE.w (SP)+,$0AFA */
  293. #if CGLUESUPPORTED
  294. extern void paramtext(const char *param0, const char *param1, const char *param2, const char *param3);
  295. extern void getdialogitemtext(Handle item, char *text);
  296. extern void setdialogitemtext(Handle item, const char *text);
  297. extern short finddialogitem(DialogRef theDialog, Point *thePt);
  298. #endif
  299. extern pascal void AppendDITL(DialogRef theDialog, Handle theHandle, DITLMethod method);
  300. extern pascal short CountDITL(DialogRef theDialog);
  301. extern pascal void ShortenDITL(DialogRef theDialog, short numberItems);
  302. extern pascal Boolean StdFilterProc(DialogRef theDialog, EventRecord *event, short *itemHit);
  303. extern pascal OSErr GetStdFilterProc(ModalFilterUPP *theProc)
  304.  THREEWORDINLINE(0x303C, 0x0203, 0xAA68);
  305. extern pascal OSErr SetDialogDefaultItem(DialogRef theDialog, short newItem)
  306.  THREEWORDINLINE(0x303C, 0x0304, 0xAA68);
  307. extern pascal OSErr SetDialogCancelItem(DialogRef theDialog, short newItem)
  308.  THREEWORDINLINE(0x303C, 0x0305, 0xAA68);
  309. extern pascal OSErr SetDialogTracksCursor(DialogRef theDialog, Boolean tracks)
  310.  THREEWORDINLINE(0x303C, 0x0306, 0xAA68);
  311. #if OLDROUTINENAMES
  312. #if !GENERATINGCFM
  313. extern pascal void CouldDialog(short dialogID)
  314.  ONEWORDINLINE(0xA979);
  315. extern pascal void FreeDialog(short dialogID)
  316.  ONEWORDINLINE(0xA97A);
  317. extern pascal void CouldAlert(short alertID)
  318.  ONEWORDINLINE(0xA989);
  319. extern pascal void FreeAlert(short alertID)
  320.  ONEWORDINLINE(0xA98A);
  321. #endif
  322. #define DisposDialog(theDialog) DisposeDialog(theDialog)
  323. #define UpdtDialog(theDialog, updateRgn) UpdateDialog(theDialog, updateRgn)
  324. #define GetDItem(theDialog, itemNo, itemType, item, box)  \
  325.     GetDialogItem(theDialog, itemNo, itemType, item, box)
  326. #define SetDItem(theDialog, itemNo, itemType, item, box)  \
  327.     SetDialogItem(theDialog, itemNo, itemType, item, box)
  328. #define HideDItem(theDialog, itemNo) HideDialogItem(theDialog, itemNo)
  329. #define ShowDItem(theDialog, itemNo) ShowDialogItem(theDialog, itemNo)
  330. #define SelIText(theDialog, itemNo, strtSel, endSel)  \
  331.     SelectDialogItemText(theDialog, itemNo, strtSel, endSel)
  332. #define GetIText(item, text) GetDialogItemText(item, text)
  333. #define SetIText(item, text) SetDialogItemText(item, text)
  334. #define FindDItem(theDialog, thePt) FindDialogItem(theDialog, thePt)
  335. #define NewCDialog(dStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon, items)  \
  336.     NewColorDialog(dStorage, boundsRect, title, visible, procID, behind,  \
  337.     goAwayFlag, refCon, items)
  338. #define GetAlrtStage() GetAlertStage()
  339. #define ResetAlrtStage() ResetAlertStage()
  340. #define DlgCut(theDialog) DialogCut(theDialog)
  341. #define DlgPaste(theDialog) DialogPaste(theDialog)
  342. #define DlgCopy(theDialog) DialogCopy(theDialog)
  343. #define DlgDelete(theDialog) DialogDelete(theDialog)
  344. #define SetDAFont(fontNum) SetDialogFont(fontNum)
  345. #if CGLUESUPPORTED
  346. #define newcdialog(dStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon, items)  \
  347.     newcolordialog(dStorage, boundsRect, title, visible, procID, behind,  \
  348.     goAwayFlag, refCon, items)
  349. #define getitext(item, text) getdialogitemtext(item, text)
  350. #define setitext(item, text) setdialogitemtext(item, text)
  351. #define findditem(theDialog, thePt) finddialogitem(theDialog, thePt)
  352. #endif
  353. #else
  354. #endif
  355. /*
  356. *****************************************************************************
  357. *                                                                           *
  358. * The conditional STRICT_DIALOGS has been removed from this interface file. *
  359. * The accessor macros to a DialogRecord are no longer necessary.            *
  360. *                                                                           *
  361. *****************************************************************************
  362.  
  363. Details:
  364. The original purpose of the STRICT_ conditionals and accessor macros was to
  365. help ease the transition to Copland.   Shared data structures are difficult
  366. to coordinate in a preemptive multitasking OS.  By hiding the fields in a
  367. WindowRecord and other data structures, we would begin the migration to 
  368. system data structures being completely hidden from applications. 
  369.  
  370. After many design reviews, it was finally concluded that with this sort of
  371. migration, the system could never tell when an application was no longer 
  372. peeking at a WindowRecord, and thus the data structure might never become 
  373. system owned.  Additionally, there were many other limitations in the classic
  374. toolbox that were begging to be addressed.
  375.  
  376. The final decision was to leave the traditional toolbox as a compatibility mode.
  377. The preferred toolbox API for Copland is a new SOM(tm) based architecture 
  378. (e.g. HIWindows.idl).  Windows, menu, controls, etc are each a SOM object 
  379. with methods for drawing, event handling, and customization.
  380.  
  381. */
  382. #ifdef __cplusplus
  383. inline WindowRef     GetDialogWindow(DialogRef dialog)        { return (WindowRef) dialog;                         }
  384. inline SInt16        GetDialogDefaultItem(DialogRef dialog)  { return (*(SInt16 *) (((UInt8 *) dialog) + 168));    }
  385. inline SInt16        GetDialogCancelItem(DialogRef dialog)     { return (*(SInt16 *) (((UInt8 *) dialog) + 166));    }
  386. inline SInt16        GetDialogKeyboardFocusItem(DialogRef dialog)    { return ((*(SInt16 *) (((UInt8 *) dialog) + 164)) < 0 ? -1 : (*(SInt16 *) (((UInt8 *) dialog) + 164)) + 1); }
  387. inline void        SetGrafPortOfDialog(DialogRef dialog) { SetPort ((GrafPtr) dialog); }
  388. #else
  389. #define GetDialogWindow(dialog)    ((WindowRef) dialog)
  390. #define GetDialogDefaultItem(dialog) (*(SInt16 *) (((UInt8 *) dialog) + 168))
  391. #define GetDialogCancelItem(dialog) (*(SInt16 *) (((UInt8 *) dialog) + 166))
  392. #define GetDialogKeyboardFocusItem(dialog) ((*(SInt16 *) (((UInt8 *) dialog) + 164)) < 0 ? -1 : (*(SInt16 *) (((UInt8 *) dialog) + 164)) + 1)
  393. #define SetGrafPortOfDialog(dialog) do { SetPort ((GrafPtr) dialog); } while (false)
  394. #endif
  395.  
  396. #if PRAGMA_IMPORT_SUPPORTED
  397. #pragma import off
  398. #endif
  399.  
  400. #if PRAGMA_ALIGN_SUPPORTED
  401. #pragma options align=reset
  402. #endif
  403.  
  404. #ifdef __cplusplus
  405. }
  406. #endif
  407.  
  408. #endif /* __DIALOGS__ */
  409.